﻿namespace CollisionDetection.Converters
{
    using System;
    using System.Globalization;
    using System.Windows.Data;
    using Models;

    [ValueConversion(typeof(EnumTipoOrigem), typeof(EnumTipoOrigem))]
    public class TipoOrigemDadosToBooleanConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null && parameter == null)
                return false;

            var param = Enum.Parse(typeof(EnumTipoOrigem), parameter.ToString());
            var checkValue = (EnumTipoOrigem)value;

            return param.Equals(checkValue);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Enum.Parse(typeof(EnumTipoOrigem), parameter.ToString());
        }

        #endregion
    }
}